import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory('/'),
  routes: [
    {
      path: '/',
      redirect: '/home',
      component: () => import('@/layout/index.vue'),
      children: [
        {
          path: '/home',
          name: 'home',
          component: () => import('@/views/home/index.vue'),
        },
        {
          path: '/account',
          name: 'account',
          component: () => import('@/views/account/index.vue'),
        },
        {
          path: '/myInfo',
          name: 'myInfo',
          component: () => import('@/views/myInfo/index.vue'),
        },
          {
          path: '/editor',
          name: 'editor',
          component: () => import('@/views/editor/index.vue'),
        },
        {
          path: '/dialog',
          name: 'dialog',
          component: () => import('@/views/dialog/index.vue'),
        }
      ],
    },
 
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/login/index.vue'),
    },
      {
      path: '/demo',
      name: 'demo',
      component: () => import('@/views/demo/index.vue'),
    },
     {
      path: '/register', //路径  这是唯一的
      name: 'register',  //全局路由名称  这是唯一的

      component: () => import('@/views/register/index.vue'),
    },
    {
      path: '/404',
      name: '404',
      component: () => import('@/views/404/index.vue'),
    },
    {
      path: '/:catchAll(.*)',
      redirect: '/404',
    },
  ],
})

export default router
